﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using PMS.BusinessFacade;
using PMS.EntityManage;
using PMS.Common;
using PMS.EntityQuery;
using System.Data.SqlClient;
using System.Collections.Generic;
using EntityManage;
using BusinessFacade;

public partial class Modules_Personal_PerfModifyForm : System.Web.UI.Page
{
    IPerf_Personal_EvaluateHandler evaHandler = new Perf_Personal_EvaluateManage();
    IPerf_Personal_EvaluateHandlerExt evaExtHandler = new Perf_Personal_EvaluateManageExt();
    IPerf_Flow_TraceHandler flowTraceHandler = new Perf_Flow_TraceManage();
    IPerf_Personal_ApprovalHandler approvalHandler = new Perf_Personal_ApprovalManage();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CheckPurviews())
        {
            Response.Redirect("~/Login.aspx");
        }
        if (!IsPostBack)
        {
            int ID = int.Parse(Request["ID"]);
            Perf_Personal_ApprovalQuery query = approvalHandler.GetPerf_Personal_ApprovalQuery(ID);
            if (query != null)
            {
                lblTitle.Text = query.Title;
                lblPerfDate.Text = query.Perf_Date.ToString();
                txtPlusScore.Text = query.Plus_Score.ToString();
                txtPlusReason.Text = query.Plus_Reason;
                txtRemark.Text = query.Remark;

            }
        }
    }

    private bool CheckPurviews()
    {
        if (Session["UserPurviews"] != null)
        {
            string strPur = Session["UserPurviews"].ToString();
            if (strPur.Contains("303060"))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            return false;
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Session["UserPurviews"] != null && Session["UserPurviews"].ToString().Contains("303060"))
        {
            int ID = int.Parse(Request["ID"]);
            Perf_Personal_ApprovalQuery query = approvalHandler.GetPerf_Personal_ApprovalQuery(ID);
            if (query != null)
            {
                query.Plus_Score = double.Parse(txtPlusScore.Text);
                query.Plus_Reason = txtPlusReason.Text;
                query.Remark = txtRemark.Text;
                approvalHandler.UpdatePerf_Personal_Approval(query);
            }
        }

        Jscript.Alert("修改成功",this.Page);
        Jscript.ReturnAndClose(this.Page, "true");
    }

}
